#ifndef EX7_23_H
#define EX7_23_H

#include <string>

class Screen {
public:
    using pos = std::string::size_type;

    Screen() = default;
    Screen(pos ht, pos wd, char c) :
        height(ht), width(wd), contents(ht* wd, c) {};

    char get() const { return contents[cursor]; }
    inline char get(pos ht, pos wd) const;
    Screen& move(pos r, pos c);

private:
    pos cursor = 0;
    pos height = 0;
    pos width = 0;
    std::string contents;
};

char Screen::get(pos ht, pos wd) const {
    pos row = ht * width;
    return contents[row + wd];
}

inline Screen& Screen::move(pos r, pos c) {
    pos row = r * width;
    cursor = row + c;
    return *this;
}

#endif // !EX7_23_H
